package Vistas;

import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import Modelos.Ingrediente;




/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class FrmActualizarIngrediente extends javax.swing.JFrame {
	private JLabel LblIngrediente;
	private JComboBox CmbIngrediente;
	private JTextField TxtCantidad;
	private JLabel LblActualizar;
	private JLabel lblkilo;
	private JButton BtnGuardar;
	private DefaultComboBoxModel CmbIngredienteModel;
	private JLabel LblCantidad;
	private Vector<Ingrediente> aux2;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	
	public FrmActualizarIngrediente() {
		super();
		initGUI();
		aux2= new Vector<Ingrediente>();
	}
	
	public void AddListener(ActionListener actionListener){
		BtnGuardar.addActionListener(actionListener);
	}
	
	public void Finalizar(){
		JOptionPane.showMessageDialog(rootPane,"Ingrediente Actualizado");
		this.dispose();
	}
	
	public Ingrediente IngredienteActualizado(){
	
		aux2.elementAt(CmbIngrediente.getSelectedIndex()).setStock(Double.valueOf(TxtCantidad.getText()));
		 return aux2.elementAt(CmbIngrediente.getSelectedIndex());
	}
	
	public void LlenarCmb(Vector<Ingrediente> arr){
		int i;
		Vector<String> aux = new Vector<String>();
		for(i=0;i<arr.size();i++)
		{
			aux.add(arr.elementAt(i).getNombre());
			aux2.add(arr.elementAt(i));
		}
		
		//aux2=arr;
		
		for(i=0;i<aux2.size();i++){
			
		}
		
		CmbIngredienteModel = 
		new DefaultComboBoxModel(
			aux	/*new String[] { "--Seleccione--", "Item Two" }*/);
	
		
		CmbIngrediente = new JComboBox();
		getContentPane().add(CmbIngrediente);
		CmbIngrediente.setModel(CmbIngredienteModel);
		CmbIngrediente.setBounds(101, 50, 125, 21);
		{
			LblActualizar = new JLabel();
			getContentPane().add(LblActualizar);
			LblActualizar.setText("Actualizar Ingrediente");
			LblActualizar.setBounds(54, 12, 181, 26);
			LblActualizar.setFont(new java.awt.Font("Segoe UI",1,16));
		}
		{
			lblkilo = new JLabel();
			getContentPane().add(lblkilo);
			lblkilo.setText("kgs.");
			lblkilo.setBounds(176, 95, 31, 19);
		}
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				LblIngrediente = new JLabel();
				getContentPane().add(LblIngrediente);
				LblIngrediente.setText("Ingrediente");
				LblIngrediente.setBounds(24, 49, 116, 22);
			}
			{
				/*ComboBoxModel CmbIngredienteModel = 
					new DefaultComboBoxModel(
							new String[] { "Item One", "Item Two" });*/
				/*CmbIngrediente = new JComboBox();
				getContentPane().add(CmbIngrediente);
				CmbIngrediente.setModel(CmbIngredienteModel);
				CmbIngrediente.setBounds(152, 13, 125, 21);*/
			}
			{
				LblCantidad = new JLabel();
				getContentPane().add(LblCantidad);
				LblCantidad.setText("Cantidad");
				LblCantidad.setBounds(24, 96, 62, 14);
			}
			{
				TxtCantidad = new JTextField();
				getContentPane().add(TxtCantidad);
				TxtCantidad.setBounds(104, 93, 66, 21);
			}
			{
				BtnGuardar = new JButton();
				getContentPane().add(BtnGuardar);
				BtnGuardar.setText("Guardar Cambios");
				BtnGuardar.setBounds(54, 144, 147, 21);
			}
			pack();
			this.setSize(319, 234);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
